"""这个脚本用来验证c3d4单元类的准确性,解决abaqus验证的问题,
发现D[1,1]未赋值,20250328 11:36:32,[已解决]
"""
# %%
import numpy as np
from EF2D.Elements import C3D4
import scipy.io as sio
import matplotlib.pyplot as plt
from typing import List,Dict
from icecream import ic
import sys
import os
from EF2D.tools import *
from EF2D import *

n1=Node(label=1,x=0,y=0,z=0)
n2=Node(label=2,x=0.10,y=0,z=0)
n3=Node(label=3,x=0,y=0.15,z=0)
n4=Node(label=4,x=0,y=0,z=0.2)
initNumpyPrintOptions()
e=C3D4(label=1,node1=n1,node2=n2,node3=n3,node4=n4,E=207e9,nu=0.3)
ic(e.B)
# ic| e.B: array([[-10.    ,   0.    ,   0.    ,  10.    ,   0.    ,   0.    ,  -0.    ,   0.    ,   0.    ,  -0.    ,   0.    ,   0.    ],
#                 [  0.    ,  -6.6667,   0.    ,   0.    ,  -0.    ,   0.    ,   0.    ,   6.6667,   0.    ,   0.    ,   0.    ,   0.    ],
#                 [  0.    ,   0.    ,  -5.    ,   0.    ,   0.    ,   0.    ,   0.    ,   0.    ,  -0.    ,   0.    ,   0.    ,   5.    ],
#                 [ -6.6667, -10.    ,   0.    ,  -0.    ,  10.    ,   0.    ,   6.6667,  -0.    ,   0.    ,   0.    ,  -0.    ,   0.    ],
#                 [  0.    ,  -5.    ,  -6.6667,   0.    ,   0.    ,  -0.    ,   0.    ,  -0.    ,   6.6667,   0.    ,   5.    ,   0.    ],
#                 [ -5.    ,   0.    , -10.    ,   0.    ,   0.    ,  10.    ,  -0.    ,   0.    ,  -0.    ,   5.    ,   0.    ,  -0.    ]])
ic(e.Ve)
# ic| e.Ve: 0.0005
ic(e.D)
# 20250328 11:36:32,[的结果]
# 1e11*array([[2.7865, 1.1942, 1.1942, 0.    , 0.    , 0.    ],
#        [1.1942, 0.    , 1.1942, 0.    , 0.    , 0.    ],
#        [1.1942, 1.1942, 2.7865, 0.    , 0.    , 0.    ],
#        [0.    , 0.    , 0.    , 0.7962, 0.    , 0.    ],
#        [0.    , 0.    , 0.    , 0.    , 0.7962, 0.    ],
#        [0.    , 0.    , 0.    , 0.    , 0.    , 0.7962]])
# 修改代码后的结果:和教材example11结果一致
ic(e.Ke*1e-10)
ic(e.Ke[1,7])
# 20250328 11:36:32,[的结果],修改D代码后结果正确
# ic| e.Ke*1e-10: array([[ 1.6697,  0.6635,  0.4976, -1.3933, -0.2654, -0.199 , -0.1769, -0.3981,  0.    , -0.0995,  0.    , -0.2986],
#                        [ 0.6635,  0.4976,  0.3317, -0.3981, -0.3981,  0.    , -0.2654,  0.    , -0.1327,  0.    , -0.0995, -0.199 ],
#                        [ 0.4976,  0.3317,  0.9233, -0.2986,  0.    , -0.3981,  0.    , -0.199 , -0.1769, -0.199 , -0.1327, -0.3483],
#                        [-1.3933, -0.3981, -0.2986,  1.3933,  0.    ,  0.    ,  0.    ,  0.3981,  0.    ,  0.    ,  0.    ,  0.2986],
#                        [-0.2654, -0.3981,  0.    ,  0.    ,  0.3981,  0.    ,  0.2654,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ],
#                        [-0.199 ,  0.    , -0.3981,  0.    ,  0.    ,  0.3981,  0.    ,  0.    ,  0.    ,  0.199 ,  0.    ,  0.    ],
#                        [-0.1769, -0.2654,  0.    ,  0.    ,  0.2654,  0.    ,  0.1769,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ],
#                        [-0.3981,  0.    , -0.199 ,  0.3981,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.199 ],
#                        [ 0.    , -0.1327, -0.1769,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.1769,  0.    ,  0.1327,  0.    ],
#                        [-0.0995,  0.    , -0.199 ,  0.    ,  0.    ,  0.199 ,  0.    ,  0.    ,  0.    ,  0.0995,  0.    ,  0.    ],
#                        [ 0.    , -0.0995, -0.1327,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.1327,  0.    ,  0.0995,  0.    ],
#                        [-0.2986, -0.199 , -0.3483,  0.2986,  0.    ,  0.    ,  0.    ,  0.199 ,  0.    ,  0.    ,  0.    ,  0.3483]])
# ic| e.Ke[1,7]: 0.0


# 20250328,悬臂梁结构个abaqus验证,结果对比不上
## array([[2.7865, 1.1942, 1.1942, 0.    , 0.    , 0.    ],
#        [1.1942, 0.    , 1.1942, 0.    , 0.    , 0.    ],
#        [1.1942, 1.1942, 2.7865, 0.    , 0.    , 0.    ],
#        [0.    , 0.    , 0.    , 0.7962, 0.    , 0.    ],
#        [0.    , 0.    , 0.    , 0.    , 0.7962, 0.    ],
#        [0.    , 0.    , 0.    , 0.    , 0.    , 0.7962]])

# %%


